package org.example.callgenerateclassobject;


import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;

/**
 *  通过读取 .class文件的方式调用
 */
public class Method2 {

    public static void main(String[] args) throws NotFoundException, CannotCompileException, IllegalAccessException, InstantiationException {
        ClassPool pool = ClassPool.getDefault();
        //设置类路径
        pool.appendClassPath("F:\\javacode\\javassistDemo\\javassistDemo\\src\\main\\java");
        CtClass ctClass = pool.get("org.example.Person");
        Object object = ctClass.toClass().newInstance();
        // 下面和通过反射的方式一样去使用
    }
}
